﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace BounceSample
{
	public partial class MainPage : PhoneApplicationPage
	{
		public static GameState BounceGameState = GameState.MainMenu;
		public static bool StateHasBeenSet = false;
		// Constructor
		public MainPage()
		{
			InitializeComponent();
		}
		
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
		}

		protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
		{
			base.OnNavigatedTo(e);
			if (!StateHasBeenSet)
			{
				StateHasBeenSet = true;
				BounceGameState = GameState.MainMenu;
				NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.Relative));
			}
			switch (BounceGameState)
			{
				case GameState.MainMenu:
					StateHasBeenSet = true;
					NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.Relative));
					return;

				case GameState.OptionsMenu:
					StateHasBeenSet = true;
					NavigationService.Navigate(new Uri("/OptionsMenu.xaml", UriKind.Relative));
					return;

				case GameState.PauseMenu:
					StateHasBeenSet = true;
					NavigationService.Navigate(new Uri("/PauseMenu.xaml", UriKind.Relative));
					return;

				case GameState.GamePlay:
					StateHasBeenSet = true;
					NavigationService.Navigate(new Uri("/GamePlay.xaml", UriKind.Relative));
					return;

				case GameState.QuitGame:
					NavigationService.GoBack();
					return;

				default:
					BounceGameState = GameState.MainMenu;
					StateHasBeenSet = true;
					NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.Relative));
					return;
			}
		}
	}
}
